/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	AMessageServiceImpl.java
 * Created：		2016年7月31日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.message;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.thor.commons.exception.ThorServiceException;
import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.message.converter.AMessageConverter;
import com.thor.palmmall.spi.common.SResponse;
import com.thor.palmmall.spi.message.SMessage;
import com.thor.palmmall.spi.message.SMessageService;

/**
 * @author wolv
 *
 */
public class AMessageServiceImpl implements AMessageService {

	@Override
	public List<AMessage> getAll(String userId) throws ThorServiceException {
		SResponse<List<SMessage>> sResponse = sMessageService.getAll(userId);
		if (sResponse.isSuccess())
			return ConverterUtil.convert(sResponse.getBody(), AMessageConverter.getInstance());
		else
			throw new ThorServiceException(sResponse.getMessage());
	}

	@Override
	public void read(String userId, String id) throws ThorServiceException {
		sMessageService.read(userId, id);
	}

	@Autowired
	private SMessageService sMessageService;
}
